﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Portal.Web.Utility;
using Portal.Core;

namespace Portal.Cms.Render
{
    public class Utility
    {
        public static string fieldRequired = "<span class='Required'>*</span>";

        public static string GetUrlDetails(string Subject, string CmsDataId, string SiteId, string ExtraInfo)
        {
            Subject = Portal.Environment.Environments.ConvertSubject(Subject);
            SiteParam OSiteParam = WebEnvironments.CreateSiteParam(SiteId);
            string HttpDataRoot = WebConfig.GetConfigFromXml(OSiteParam, "HttpAdminRoot");
            string Url = "";
            if (!string.IsNullOrEmpty(ExtraInfo))
            {
                Url = HttpDataRoot + "/" + Subject + "-action-" + ExtraInfo + "-nd-" + CmsDataId + "." + Portal.Environment.Environments.Extension;
            }
            else
            {
                Url = HttpDataRoot + "/" + Subject + "-nd-" + CmsDataId + "." + Portal.Environment.Environments.Extension;
            }
            return Url;
        }

        public static string GetUrlHistory(string Subject, string CmsDataId, string SiteId, string HistoryDataId)
        {
            Subject = Portal.Environment.Environments.ConvertSubject(Subject);
            SiteParam OSiteParam = WebEnvironments.CreateSiteParam(SiteId);
            string HttpDataRoot = WebConfig.GetConfigFromXml(OSiteParam, "HttpAdminRoot");
            string Url = "";
            Url = HttpDataRoot + "/" + Subject + HistoryDataId + "-nd-" + CmsDataId + "." + Portal.Environment.Environments.Extension;
            return Url;
        }

        public static string GetUrlUpdate(string Subject, string CmsDataId, SiteParam OSiteParam)
        {
            string HttpDataRoot = WebConfig.GetConfigFromXml(OSiteParam, "HttpAdminRoot");
            string Url = HttpDataRoot + "/" + Subject + "-ud-" + CmsDataId + "." + "aspx";
            return Url;
        }
    }
}
